//
//  IconPickerViewController.swift
//  Todo-List
//
//  Created by jiangdan on 2019/9/25.
//  Copyright © 2019年 stu. All rights reserved.
//

import UIKit

protocol IconPickerViewControllerDelegate:class {
    func iconPicker(_ picker:IconPickerViewController,didPick iconName:String)
}


class IconPickerViewController: UITableViewController {
    weak var delegate:IconPickerViewControllerDelegate?
    
    let icons = ["No Icon","Appointents",
                 "Birthdays",
                 "Chores",
                 "Drinks",
                 "Floader",
                 "Groceries",
                 "Inbox",
                 "Photos",
                 "Trops"]
    let iconNames = ["不显示图标",
                     "预约",
                     "生日",
                     "家务",
                     "酒宴",
                     "文件",
                     "杂货",
                     "收件箱",
                     "照片",
                     "出行"]

    override func viewDidLoad() {
        super.viewDidLoad()

       
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return icons.count
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Iconcell", for: indexPath)
        
        cell.textLabel!.text = iconNames[indexPath.row]
        cell.imageView!.image = UIImage(named:icons[indexPath.row])
        
        return cell
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if let delegate = delegate {
            let iconName = icons[indexPath.row]
            delegate.iconPicker(self, didPick: iconName)
        }
    }
    

}
